﻿using System;

namespace CardGameCore.Battle
{
    public class DamageHandler : IDamageHandler
    {
        public IEvent Process(Card card, object target)
        {
            if (target is Actor actor)
            {
                actor.Hp = Math.Max(0, actor.Hp - card.Attack);
            }

            if (target is Card cardTarget)
            {
                cardTarget.Hp = Math.Max(0, cardTarget.Hp - card.Attack);
            }

            var @event = DamageEvent.Pool.Get();
            @event.Damage = card.Attack;
            @event.Target = target;

            return @event;
        }
    }
}